package br.com.jk.financeiro.banco;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.hibernate.annotations.NaturalId;

/**
 * "Teste de alteração"
 *
 * @author camilo
 */
@Entity
@Table(name = BancoDao.NAME_TABLE, schema = BancoDao.NAME_SCHEMA)
public class Banco implements Serializable {

  public static final String ATTRIBUTE_ID = "id";
  public static final String ATTRIBUTE_COD = "cod";
  public static final String ATTRIBUTE_DESCRICAO = "descricao";
  public static final String ATTRIBUTE_ABREVIADO = "abreviado";
  @Id
  @SequenceGenerator(name = BancoDao.NAME_SEQUENCE, sequenceName = BancoDao.NAME_SEQUENCE,
          schema = BancoDao.NAME_SCHEMA)
  @GeneratedValue(strategy = GenerationType.AUTO, generator = BancoDao.NAME_SEQUENCE)
  private int id;
  @NaturalId
  @Column(name = BancoDao.NAME_COLUMN_COD, length = 3)
  private String cod;
  @Column(nullable = false, name = BancoDao.NAME_COLUMN_DESCRICAO)
  private String descricao;
  @Column(name = BancoDao.NAME_COLUMN_ABREVIADO, nullable = false)
  private String abreviado;

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getCod() {
    return cod;
  }

  public void setCod(String cod) {
    this.cod = cod;
  }

  public String getDescricao() {
    return descricao;
  }

  public void setDescricao(String descricao) {
    this.descricao = descricao;
  }

  public String getAbreviado() {
    return abreviado;
  }

  public void setAbreviado(String abreviado) {
    this.abreviado = abreviado;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 71 * hash + this.id;
    hash = 71 * hash + Objects.hashCode(this.cod);
    hash = 71 * hash + Objects.hashCode(this.descricao);
    hash = 71 * hash + Objects.hashCode(this.abreviado);
    return hash;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Banco other = (Banco) obj;
    if (this.id != other.id) {
      return false;
    }
    if (!Objects.equals(this.cod, other.cod)) {
      return false;
    }
    if (!Objects.equals(this.descricao, other.descricao)) {
      return false;
    }
    if (!Objects.equals(this.abreviado, other.abreviado)) {
      return false;
    }
    return true;
  }
}
